package com.bckj.fastboot.iot.data.mysql.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bckj.fastboot.iot.common.dto.query.IotDeviceStatusRecordQuery;
import com.bckj.fastboot.iot.common.dto.response.IotDeviceStatusRecordResponse;
import com.bckj.fastboot.iot.data.mysql.entity.IotDeviceStatusRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

/**
 * IotDeviceStatusRecordMapper
 *
 * @author wfc
 * @date 2025/10/13 11:18
 **/
@Mapper
public interface IotDeviceStatusRecordMapper extends BaseMapper<IotDeviceStatusRecord> {

    @SelectProvider(type = IotDeviceStatusRecordProvider.class, method = "findList")
    List<IotDeviceStatusRecordResponse> findList(IotDeviceStatusRecordQuery query);

    class IotDeviceStatusRecordProvider {
        public String findList(IotDeviceStatusRecordQuery query) {
            SQL sql = new SQL();
            sql.SELECT("*");
            sql.FROM("iot_device_status_record");
            sql.WHERE("dev_id=#{devId}");
            sql.ORDER_BY("id desc");
            return sql.toString();
        }

    }
}
